/*
 * common.h
 *
 *      This header includes the common C++ libraries used in our shaper program.
 *      Also in this header are two inline functions used for printing Errors and DEBUG messages.
 */

#ifndef COMMON_H_
#define COMMON_H_

/**
 * Buffer size used in our shaper sockets.
 */
#define BUFFER_SIZE  65536
#define SESSION_TABLE_SIZE 65536
#define HTTP_FIELD_SIZE 1500
#define MAX_IP_ADDRESS_SIZE 15
#define RTT_GAP 500
#define BUFFER_ALLOWED 25
#define CYCLE_LENGHT 2

#define WIRED 4
#define _200OK 3
#define GET 2
#define SYN 1
#define RAW 0

#define TEXT 0
#define FLV 1
#define MPEG 2
#define AVI 3
#define MOV 4
#define UNKNOWN 5

#define DEBUG_STATE 0   //0-enabled  1-disabled
#define ERROR_STATE 1   //0-enabled  1-disabled

#define MAX_DEVICE_NAME (50)

#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <byteswap.h>
#include <stdint.h>
#include <pcap.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>/* protocol_type */
#include <arpa/inet.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>/* tcp header */
#include <netinet/udp.h>/* udp header */
#include <math.h>
#include <string>
//*********include for cPing***************
#include <arpa/inet.h>
//#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/time.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
//#include <netinet/ip_var.h>
#include <netdb.h>
#include <stdint.h>
#include <sstream>

using namespace std;


/**
 * The function prints out an error message to std.
 * @param string msg - The error message to print out to std.
 */
inline void ERROR(string msg){
	if(DEBUG_STATE)
		cout << "ERROR: " << msg << endl;
}

/**
 * The function prints out a debug message to std.
 * @param string msg - The debug message to print out to std.
 */
inline void DEBUG(string msg){
	if(ERROR_STATE)
		cout << "DEBUG: " << msg << endl;
}


typedef enum
{
	S_ERROR = 0,
	OK = 1,
} STATE;

typedef enum
{
	ENUM_INTERNAL_PACKET = 0,
	ENUM_EXTERNAL_PACKET = 1
} EPacketDirection;


#endif /* COMMON_H_ */
